package com.atguigu10._enum.exer1;

/**
 * ClassName: BankTest1
 * Package: com.atguigu10._enum.exer1
 * Description:
 *  使用枚举类实现单例模式--jdk5.0之前/jdk5.0中
 * @Author ZY
 * @Create 23:09
 * @Version 1.0
 */
public class BankTest1 {
    public static void main(String[] args) {
//        Bank1.instance = null;
        System.out.println(GirlFriend.XIAOHONG);

    }
}

//jdk5.0之前的使用枚举类定义单例模式
class Bank1{
    private Bank1(){}

    public static final Bank1 instance = new Bank1();

}

//jdk5.0中，使用枚举类定义单例模式
enum Bank2{
    CPB;
}

enum GirlFriend{
    XIAOHONG(20);
    private final int age;
    private GirlFriend(int age){
        this.age = age;
    }
}


